package com.shanyu.wechat.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.GsonTypeHandler;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description: 实时同步任务
 * @Author: wangsixian
 * @Date: 2021-01-22
 * @Version: V1.0
 */
@Data
@TableName(value = "message", autoResultMap = true)
@Accessors(chain = true)
public class MessageEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    private String message;
    private String wcId;
    private String account;
    private Integer messageType;
    @TableField(typeHandler = GsonTypeHandler.class)
    private MessageData data;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Data
    public static class MessageData implements Serializable {
        private String content;
        private String fromUser;
        private String msgId;
        private String newMsgId;
        private String self;
        private String timestamp;
        private String toUser;
        private String wId;
        private String fromGroup;
        private String msgSource;
        private String img;
        private String voiceLength;
    }
}
